<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>JavaScript 引擎 | Justic</title><meta name="keywords" content="JavaScript"><meta name="author" content="Justic"><meta name="copyright" content="Justic"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="一、浏览器工作原理浏览器执行过程： 二、认识浏览器内核我们经常会说：不同的浏览器有不同的内核组成 Gecko：早期被 Netscape 和 Mozilla Firefox 浏览器浏览器使用； Trident：微软开发，被 IE4~IE11 浏览器使用，但是 Edge 浏览器已经转向 Blink； Webkit：苹果基于 KHTML 开发、开源的，用于 Safari，Google Chrome">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaScript 引擎">
<meta property="og:url" content="http://example.com/2022/07/07/JavaScript/JavaScript%E5%BC%95%E6%93%8E/index.html">
<meta property="og:site_name" content="Justic">
<meta property="og:description" content="一、浏览器工作原理浏览器执行过程： 二、认识浏览器内核我们经常会说：不同的浏览器有不同的内核组成 Gecko：早期被 Netscape 和 Mozilla Firefox 浏览器浏览器使用； Trident：微软开发，被 IE4~IE11 浏览器使用，但是 Edge 浏览器已经转向 Blink； Webkit：苹果基于 KHTML 开发、开源的，用于 Safari，Google Chrome">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://pic1.zhimg.com/v2-4dce785ff4595de55623611ab0055d33_1440w.jpg?source=172ae18b">
<meta property="article:published_time" content="2022-07-07T12:05:37.000Z">
<meta property="article:modified_time" content="2022-07-08T13:43:47.180Z">
<meta property="article:author" content="Justic">
<meta property="article:tag" content="JavaScript">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic1.zhimg.com/v2-4dce785ff4595de55623611ab0055d33_1440w.jpg?source=172ae18b"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2022/07/07/JavaScript/JavaScript%E5%BC%95%E6%93%8E/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'JavaScript 引擎',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-07-08 21:43:47'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css" /><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.2.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://portrait.gitee.com/uploads/avatars/user/2982/8948190_JIAXInT_1624177607.png!avatar200" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">22</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">2</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/project/"><i class="fa-fw fas fa-images"></i><span> 项目</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于笔者</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://pic1.zhimg.com/v2-4dce785ff4595de55623611ab0055d33_1440w.jpg?source=172ae18b')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Justic</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-graduation-cap"></i><span> 博文</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/project/"><i class="fa-fw fas fa-images"></i><span> 项目</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于笔者</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">JavaScript 引擎</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-07-07T12:05:37.000Z" title="发表于 2022-07-07 20:05:37">2022-07-07</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-07-08T13:43:47.180Z" title="更新于 2022-07-08 21:43:47">2022-07-08</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/JavaScript/">JavaScript</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="JavaScript 引擎"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/2022/07/07/JavaScript/JavaScript%E5%BC%95%E6%93%8E/#post-comment" itemprop="discussionUrl"><span class="valine-comment-count" data-xid="/2022/07/07/JavaScript/JavaScript%E5%BC%95%E6%93%8E/" itemprop="commentCount"><i class="fa-solid fa-spinner fa-spin"></i></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><meta name="referrer" content="no-referrer">

<h1 id="一、浏览器工作原理"><a href="#一、浏览器工作原理" class="headerlink" title="一、浏览器工作原理"></a>一、浏览器工作原理</h1><p>浏览器执行过程：<br><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2021/png/21707377/1638355192875-ac69b240-3bea-4057-a517-cf6669b37f43.png#clientId=uf3c6c3d5-c0ad-4&from=paste&height=426&id=u06d06c92&margin=%5Bobject%20Object%5D&name=image.png&originHeight=568&originWidth=1345&originalType=binary&ratio=1&size=449837&status=done&style=shadow&taskId=uf9ed310b-45db-4a4e-8046-de278b8713a&width=1009" alt="image.png"></p>
<h1 id="二、认识浏览器内核"><a href="#二、认识浏览器内核" class="headerlink" title="二、认识浏览器内核"></a>二、认识浏览器内核</h1><h3 id="我们经常会说：不同的浏览器有不同的内核组成"><a href="#我们经常会说：不同的浏览器有不同的内核组成" class="headerlink" title="我们经常会说：不同的浏览器有不同的内核组成"></a>我们经常会说：不同的浏览器有不同的内核组成</h3><ul>
<li>Gecko：早期被 Netscape 和 Mozilla Firefox 浏览器浏览器使用；</li>
<li>Trident：微软开发，被 IE4~IE11 浏览器使用，但是 Edge 浏览器已经转向 Blink；</li>
<li>Webkit：苹果基于 KHTML 开发、开源的，用于 Safari，Google Chrome 之前也在使用；</li>
<li>Blink：是 Webkit 的一个分支，Google 开发，目前应用于 Google Chrome、Edge、Opera 等；</li>
<li>等等…</li>
</ul>
<h3 id="事实上，我们经常说的浏览器内核指的是浏览器的排版引擎："><a href="#事实上，我们经常说的浏览器内核指的是浏览器的排版引擎：" class="headerlink" title="事实上，我们经常说的浏览器内核指的是浏览器的排版引擎："></a>事实上，我们经常说的浏览器内核指的是浏览器的排版引擎：</h3><p><strong>排版引擎</strong>（layout engine），也称为<strong>浏览器引擎</strong>（browser engine）、<strong>页面渲染引擎</strong>（rendering engine）<br>或<strong>样版引擎</strong>。</p>
<h1 id="三、浏览器渲染过程"><a href="#三、浏览器渲染过程" class="headerlink" title="三、浏览器渲染过程"></a>三、浏览器渲染过程</h1><h3 id="但是在这个执行过程中，HTML-解析的时候遇到了-JavaScript-标签，应该怎么办呢？"><a href="#但是在这个执行过程中，HTML-解析的时候遇到了-JavaScript-标签，应该怎么办呢？" class="headerlink" title="但是在这个执行过程中，HTML 解析的时候遇到了 JavaScript 标签，应该怎么办呢？"></a>但是在这个执行过程中，HTML 解析的时候遇到了 JavaScript 标签，应该怎么办呢？</h3><p><strong>会停止解析 HTML，而去加载和执行 JavaScript 代码；</strong><br><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2021/png/21707377/1638355474986-fcfe3f2e-4f5d-4f15-a54d-e2675b2a9d1b.png#clientId=uf3c6c3d5-c0ad-4&from=paste&id=u3e5fa593&margin=%5Bobject%20Object%5D&name=image.png&originHeight=423&originWidth=974&originalType=binary&ratio=1&size=88111&status=done&style=shadow&taskId=ubeed8532-1dd3-4f68-93fe-5f8e95077d2" alt="image.png"></p>
<h3 id="那么，JavaScript-代码由谁来执行呢？"><a href="#那么，JavaScript-代码由谁来执行呢？" class="headerlink" title="那么，JavaScript 代码由谁来执行呢？"></a>那么，JavaScript 代码由谁来执行呢？</h3><p><strong>答案是：JavaScript 引擎</strong></p>
<h1 id="四、认识-JavaScript-引擎"><a href="#四、认识-JavaScript-引擎" class="headerlink" title="四、认识 JavaScript 引擎"></a>四、认识 JavaScript 引擎</h1><h3 id="为什么需要-JavaScript-引擎呢？"><a href="#为什么需要-JavaScript-引擎呢？" class="headerlink" title="为什么需要 JavaScript 引擎呢？"></a>为什么需要 JavaScript 引擎呢？</h3><pre><code>  - 我们前面说过，高级的编程语言都是需要转成最终的机器指令来执行的；
  - 事实上我们编写的JavaScript无论你交给浏览器或者Node执行，最后都是需要被CPU执行的；
  - 但是CPU只认识自己的指令集，实际上是机器语言，才能被CPU所执行；
  - 所以我们需要JavaScript引擎帮助我们将JavaScript代码翻译成CPU指令来执行；
</code></pre>
<h3 id="比较常见的-JavaScript-引擎都有哪些呢？"><a href="#比较常见的-JavaScript-引擎都有哪些呢？" class="headerlink" title="比较常见的 JavaScript 引擎都有哪些呢？"></a>比较常见的 JavaScript 引擎都有哪些呢？</h3><pre><code>  - **SpiderMonkey**：第一款JavaScript引擎，由Brendan Eich开发（也就是JavaScript作者）；
  - **Chakra**：微软开发，用于IT浏览器；
  - **JavaScriptCore：**WebKit中的JavaScript引擎，Apple公司开发；
  - **V8**：Google开发的强大JavaScript引擎，也帮助Chrome从众多浏览器中脱颖而出；
  - 等等…
</code></pre>
<h1 id="五、浏览器内核和-JS-引擎的关系"><a href="#五、浏览器内核和-JS-引擎的关系" class="headerlink" title="五、浏览器内核和 JS 引擎的关系"></a>五、浏览器内核和 JS 引擎的关系</h1><h3 id="这里我们先以-WebKit-为例，WebKit-实际上由两部分组成"><a href="#这里我们先以-WebKit-为例，WebKit-实际上由两部分组成" class="headerlink" title="这里我们先以 WebKit 为例，WebKit 实际上由两部分组成"></a>这里我们先以 WebKit 为例，WebKit 实际上由两部分组成</h3><pre><code>  - **WebCore**：负责HTML解析、布局、渲染等等相关的工作；
  - **JavaScriptCore**：解析、执行JavaScript代码；
</code></pre>
<h3 id="在小程序中编写的-JavaScript-代码就是被-JSCore-执行的"><a href="#在小程序中编写的-JavaScript-代码就是被-JSCore-执行的" class="headerlink" title="在小程序中编写的 JavaScript 代码就是被 JSCore 执行的"></a>在小程序中编写的 JavaScript 代码就是被 JSCore 执行的</h3><p><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2021/png/21707377/1638358535971-dd52f08a-52fe-4f5a-8e0c-b55f596c26d9.png#clientId=uf3c6c3d5-c0ad-4&from=paste&id=ua8dc05d3&margin=%5Bobject%20Object%5D&name=image.png&originHeight=364&originWidth=979&originalType=binary&ratio=1&size=312584&status=done&style=shadow&taskId=u397563a2-265a-469e-8b4e-60ac1135a3b" alt="image.png"><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2021/png/21707377/1638358568312-3eb9beb4-6655-49e6-ab59-5d4ac1d270d6.png#clientId=uf3c6c3d5-c0ad-4&from=paste&id=u9271a581&margin=%5Bobject%20Object%5D&name=image.png&originHeight=499&originWidth=699&originalType=binary&ratio=1&size=233979&status=done&style=shadow&taskId=u08efab4b-f562-48cb-b3bd-a978c7b0459" alt="image.png"></p>
<h3 id="另外一个强大的-JavaScript-引擎就是-V8-引擎"><a href="#另外一个强大的-JavaScript-引擎就是-V8-引擎" class="headerlink" title="另外一个强大的 JavaScript 引擎就是 V8 引擎"></a>另外一个强大的 JavaScript 引擎就是 V8 引擎</h3><h1 id="六、V8-引擎原理"><a href="#六、V8-引擎原理" class="headerlink" title="六、V8 引擎原理"></a>六、V8 引擎原理</h1><h3 id="我们来看一下官方对-V8-引擎的定义："><a href="#我们来看一下官方对-V8-引擎的定义：" class="headerlink" title="我们来看一下官方对 V8 引擎的定义："></a>我们来看一下官方对 V8 引擎的定义：</h3><pre><code>  - V8是用C ++编写的Google开源高性能JavaScript和WebAssembly引擎，它用于Chrome和Node.js等。
  - 它实现ECMAScript和WebAssembly，并在Windows 7或更高版本，macOS 10.12+和使用x64，IA-32，ARM或MIPS处理器的Linux系统上运行。
  - V8可以独立运行，也可以嵌入到任何C ++应用程序中。
</code></pre>
<p><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2021/png/21707377/1638358787996-bc995c0b-33ea-453a-a85c-6a4ef2379865.png#clientId=uf3c6c3d5-c0ad-4&from=paste&height=208&id=u1c251b20&margin=%5Bobject%20Object%5D&name=image.png&originHeight=416&originWidth=1700&originalType=binary&ratio=1&size=493669&status=done&style=shadow&taskId=ua6633b86-cd6f-4a20-ad49-adb062bb625&width=850" alt="image.png"></p>
<h1 id="七、V8-引擎的架构"><a href="#七、V8-引擎的架构" class="headerlink" title="七、V8 引擎的架构"></a>七、V8 引擎的架构</h1><h3 id="V8-引擎本身的源码非常复杂，大概有超过-100w-行-C-代码，通过了解它的架构，我们可以知道它是如何对-JavaScript-执行的："><a href="#V8-引擎本身的源码非常复杂，大概有超过-100w-行-C-代码，通过了解它的架构，我们可以知道它是如何对-JavaScript-执行的：" class="headerlink" title="V8 引擎本身的源码非常复杂，大概有超过 100w 行 C++代码，通过了解它的架构，我们可以知道它是如何对 JavaScript 执行的："></a>V8 引擎本身的源码非常复杂，大概有超过 100w 行 C++代码，通过了解它的架构，我们可以知道它是如何对 JavaScript 执行的：</h3><h4 id="Parse-模块会将-JavaScript-代码转换成-AST（抽象语法树），这是因为解释器并不直接认识-JavaScript-代码；"><a href="#Parse-模块会将-JavaScript-代码转换成-AST（抽象语法树），这是因为解释器并不直接认识-JavaScript-代码；" class="headerlink" title="Parse 模块会将 JavaScript 代码转换成 AST（抽象语法树），这是因为解释器并不直接认识 JavaScript 代码；"></a>Parse 模块会将 JavaScript 代码转换成 AST（抽象语法树），这是因为解释器并不直接认识 JavaScript 代码；</h4><pre><code>  -  如果函数没有被调用，那么是不会被转换成AST的；
  -  Parse的V8官方文档：[https://v8.dev/blog/scanner](https://v8.dev/blog/scanner)
</code></pre>
<h4 id="Ignition-是一个解释器，会将-AST-转换成-ByteCode（字节码）"><a href="#Ignition-是一个解释器，会将-AST-转换成-ByteCode（字节码）" class="headerlink" title="Ignition 是一个解释器，会将 AST 转换成 ByteCode（字节码）"></a>Ignition 是一个解释器，会将 AST 转换成 ByteCode（字节码）</h4><pre><code>  -  同时会收集TurboFan优化所需要的信息（比如函数参数的类型信息，有了类型才能进行真实的运算）；
  -  如果函数只调用一次，Ignition会执行解释执行ByteCode；
  -  Ignition的V8官方文档：[https://v8.dev/blog/ignition-interpreter](https://v8.dev/blog/ignition-interpreter)
</code></pre>
<h4 id="TurboFan-是一个编译器，可以将字节码编译为-CPU-可以直接执行的机器码；"><a href="#TurboFan-是一个编译器，可以将字节码编译为-CPU-可以直接执行的机器码；" class="headerlink" title="TurboFan 是一个编译器，可以将字节码编译为 CPU 可以直接执行的机器码；"></a>TurboFan 是一个编译器，可以将字节码编译为 CPU 可以直接执行的机器码；</h4><pre><code>  -  如果一个函数被多次调用，那么就会被标记为热点函数，那么就会经过TurboFan转换成优化的机器码，提高代码的执行性能；
  -  但是，机器码实际上也会被还原为ByteCode，这是因为如果后续执行函数的过程中，类型发生了变化（比如sum函数原来执行的是number类型，后来执行变成了string类型），之前优化的机器码并不能正确的处理运算，就会逆向的转换成字节码；
  -  TurboFan的V8官方文档：[https://v8.dev/blog/turbofan-jit](https://v8.dev/blog/turbofan-jit)
</code></pre>
<h1 id="八、V8-引擎的官方解析图"><a href="#八、V8-引擎的官方解析图" class="headerlink" title="八、V8 引擎的官方解析图"></a>八、V8 引擎的官方解析图</h1><p><img src= "" data-lazy-src="https://cdn.nlark.com/yuque/0/2021/png/21707377/1638359184054-b042af71-f4cb-4b9d-ae5d-96e8a99696b6.png#clientId=uf3c6c3d5-c0ad-4&from=paste&height=364&id=ud40fb0cf&margin=%5Bobject%20Object%5D&name=image.png&originHeight=727&originWidth=1543&originalType=binary&ratio=1&size=289493&status=done&style=shadow&taskId=uc2706ba6-dca6-46af-97e6-bf2f265985e&width=771.5" alt="image.png"></p>
<h1 id="九、V8-执行的细节"><a href="#九、V8-执行的细节" class="headerlink" title="九、V8 执行的细节"></a>九、V8 执行的细节</h1><h3 id="那么我们的-JavaScript-源码是如何被解析（Parse-过程）的呢？"><a href="#那么我们的-JavaScript-源码是如何被解析（Parse-过程）的呢？" class="headerlink" title="那么我们的 JavaScript 源码是如何被解析（Parse 过程）的呢？"></a>那么我们的 JavaScript 源码是如何被解析（Parse 过程）的呢？</h3><ul>
<li>Blink 将源码交给 V8 引擎，Stream 获取到源码并且进行编码转换；</li>
<li>Scanner 会进行词法分析（lexical analysis），词法分析会将代码转换成 tokens；</li>
<li>接下来 tokens 会被转换成 AST 树，经过 Parser 和 PreParser：<ul>
<li>Parser 就是直接将 tokens 转成 AST 树架构；</li>
<li>PreParser 称之为预解析，为什么需要预解析呢？ - 这是因为并不是所有的 JavaScript 代码，在一开始时就会被执行。那么对所有的 JavaScript 代码进行解析，必然会<br>影响网页的运行效率； - 所以 V8 引擎就实现了 Lazy Parsing（延迟解析）的方案，它的作用是将不必要的函数进行预解析，也就是只解析暂<br>时需要的内容，而对函数的全量解析是在函数被调用时才会进行； - 比如我们在一个函数 outer 内部定义了另外一个函数 inner，那么 inner 函数就会进行预解析；</li>
</ul>
</li>
<li>生成 AST 树后，会被 Ignition 转成字节码（bytecode），之后的过程就是代码的执行过程（后续会详细分析）。</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">Justic</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2022/07/07/JavaScript/JavaScript%E5%BC%95%E6%93%8E/">http://example.com/2022/07/07/JavaScript/JavaScript引擎/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://justicc.top/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">Justic</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/JavaScript/">JavaScript</a></div><div class="post_share"><div class="social-share" data-image="https://pic1.zhimg.com/v2-4dce785ff4595de55623611ab0055d33_1440w.jpg?source=172ae18b" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/img/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/2022/07/13/Vue/Vue%E5%9F%BA%E7%A1%80/Vue%E5%9F%BA%E7%A1%80/"><img class="prev-cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/yj/wallhaven-yj1kgl.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Vue 基础</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2022/07/22/JavaScript/JavaScript%E5%87%BD%E6%95%B0this%E6%8C%87%E5%90%91/JavaScript%E5%87%BD%E6%95%B0this%E6%8C%87%E5%90%91/" title="JavaScript函数this指向"><img class="cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/k7/wallhaven-k7jmg6.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-22</div><div class="title">JavaScript函数this指向</div></div></a></div><div><a href="/2022/07/13/JavaScript/JavaScript%20%E9%9D%A2%E8%AF%95%E7%B2%BE%E8%AE%B2/JavaScript%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/" title="JavaScript 性能优化"><img class="cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/3z/wallhaven-3zgz2y.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-13</div><div class="title">JavaScript 性能优化</div></div></a></div><div><a href="/2022/07/13/JavaScript/JavaScript%20%E9%9D%A2%E8%AF%95%E7%B2%BE%E8%AE%B2/JavaScript%E5%BC%82%E6%AD%A5%E7%BC%96%E7%A8%8B/" title="JavaScript 异步编程"><img class="cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/j3/wallhaven-j3qq15.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-13</div><div class="title">JavaScript 异步编程</div></div></a></div><div><a href="/2022/07/13/JavaScript/JavaScript%20%E9%9D%A2%E8%AF%95%E7%B2%BE%E8%AE%B2/%E6%A8%A1%E5%9D%97%E5%8C%96/" title="JavaScript 模块化"><img class="cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/m9/wallhaven-m9y289.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-13</div><div class="title">JavaScript 模块化</div></div></a></div><div><a href="/2022/08/08/JavaScript/JavaScript%E5%87%BD%E6%95%B0%E5%A2%9E%E5%BC%BA%E7%9F%A5%E8%AF%86/index/" title="JavaScript函数增强知识"><img class="cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/28/wallhaven-2881yx.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-08</div><div class="title">JavaScript函数增强知识</div></div></a></div><div><a href="/2022/07/13/JavaScript/JavaScript%20%E9%9D%A2%E8%AF%95%E7%B2%BE%E8%AE%B2/JavaScript%E9%9D%A2%E8%AF%95%E7%B2%BE%E8%AE%B2/" title="JavaScript 精讲"><img class="cover" src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/z8/wallhaven-z82evv.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-13</div><div class="title">JavaScript 精讲</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://portrait.gitee.com/uploads/avatars/user/2982/8948190_JIAXInT_1624177607.png!avatar200" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Justic</div><div class="author-info__description">最是人间留不住 朱颜辞镜花辞树</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">22</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">2</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E6%B5%8F%E8%A7%88%E5%99%A8%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86"><span class="toc-text">一、浏览器工作原理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E8%AE%A4%E8%AF%86%E6%B5%8F%E8%A7%88%E5%99%A8%E5%86%85%E6%A0%B8"><span class="toc-text">二、认识浏览器内核</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%88%91%E4%BB%AC%E7%BB%8F%E5%B8%B8%E4%BC%9A%E8%AF%B4%EF%BC%9A%E4%B8%8D%E5%90%8C%E7%9A%84%E6%B5%8F%E8%A7%88%E5%99%A8%E6%9C%89%E4%B8%8D%E5%90%8C%E7%9A%84%E5%86%85%E6%A0%B8%E7%BB%84%E6%88%90"><span class="toc-text">我们经常会说：不同的浏览器有不同的内核组成</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8B%E5%AE%9E%E4%B8%8A%EF%BC%8C%E6%88%91%E4%BB%AC%E7%BB%8F%E5%B8%B8%E8%AF%B4%E7%9A%84%E6%B5%8F%E8%A7%88%E5%99%A8%E5%86%85%E6%A0%B8%E6%8C%87%E7%9A%84%E6%98%AF%E6%B5%8F%E8%A7%88%E5%99%A8%E7%9A%84%E6%8E%92%E7%89%88%E5%BC%95%E6%93%8E%EF%BC%9A"><span class="toc-text">事实上，我们经常说的浏览器内核指的是浏览器的排版引擎：</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E6%B5%8F%E8%A7%88%E5%99%A8%E6%B8%B2%E6%9F%93%E8%BF%87%E7%A8%8B"><span class="toc-text">三、浏览器渲染过程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BD%86%E6%98%AF%E5%9C%A8%E8%BF%99%E4%B8%AA%E6%89%A7%E8%A1%8C%E8%BF%87%E7%A8%8B%E4%B8%AD%EF%BC%8CHTML-%E8%A7%A3%E6%9E%90%E7%9A%84%E6%97%B6%E5%80%99%E9%81%87%E5%88%B0%E4%BA%86-JavaScript-%E6%A0%87%E7%AD%BE%EF%BC%8C%E5%BA%94%E8%AF%A5%E6%80%8E%E4%B9%88%E5%8A%9E%E5%91%A2%EF%BC%9F"><span class="toc-text">但是在这个执行过程中，HTML 解析的时候遇到了 JavaScript 标签，应该怎么办呢？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%82%A3%E4%B9%88%EF%BC%8CJavaScript-%E4%BB%A3%E7%A0%81%E7%94%B1%E8%B0%81%E6%9D%A5%E6%89%A7%E8%A1%8C%E5%91%A2%EF%BC%9F"><span class="toc-text">那么，JavaScript 代码由谁来执行呢？</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9B%9B%E3%80%81%E8%AE%A4%E8%AF%86-JavaScript-%E5%BC%95%E6%93%8E"><span class="toc-text">四、认识 JavaScript 引擎</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81-JavaScript-%E5%BC%95%E6%93%8E%E5%91%A2%EF%BC%9F"><span class="toc-text">为什么需要 JavaScript 引擎呢？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%AF%94%E8%BE%83%E5%B8%B8%E8%A7%81%E7%9A%84-JavaScript-%E5%BC%95%E6%93%8E%E9%83%BD%E6%9C%89%E5%93%AA%E4%BA%9B%E5%91%A2%EF%BC%9F"><span class="toc-text">比较常见的 JavaScript 引擎都有哪些呢？</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BA%94%E3%80%81%E6%B5%8F%E8%A7%88%E5%99%A8%E5%86%85%E6%A0%B8%E5%92%8C-JS-%E5%BC%95%E6%93%8E%E7%9A%84%E5%85%B3%E7%B3%BB"><span class="toc-text">五、浏览器内核和 JS 引擎的关系</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%99%E9%87%8C%E6%88%91%E4%BB%AC%E5%85%88%E4%BB%A5-WebKit-%E4%B8%BA%E4%BE%8B%EF%BC%8CWebKit-%E5%AE%9E%E9%99%85%E4%B8%8A%E7%94%B1%E4%B8%A4%E9%83%A8%E5%88%86%E7%BB%84%E6%88%90"><span class="toc-text">这里我们先以 WebKit 为例，WebKit 实际上由两部分组成</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%BC%96%E5%86%99%E7%9A%84-JavaScript-%E4%BB%A3%E7%A0%81%E5%B0%B1%E6%98%AF%E8%A2%AB-JSCore-%E6%89%A7%E8%A1%8C%E7%9A%84"><span class="toc-text">在小程序中编写的 JavaScript 代码就是被 JSCore 执行的</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8F%A6%E5%A4%96%E4%B8%80%E4%B8%AA%E5%BC%BA%E5%A4%A7%E7%9A%84-JavaScript-%E5%BC%95%E6%93%8E%E5%B0%B1%E6%98%AF-V8-%E5%BC%95%E6%93%8E"><span class="toc-text">另外一个强大的 JavaScript 引擎就是 V8 引擎</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%AD%E3%80%81V8-%E5%BC%95%E6%93%8E%E5%8E%9F%E7%90%86"><span class="toc-text">六、V8 引擎原理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%88%91%E4%BB%AC%E6%9D%A5%E7%9C%8B%E4%B8%80%E4%B8%8B%E5%AE%98%E6%96%B9%E5%AF%B9-V8-%E5%BC%95%E6%93%8E%E7%9A%84%E5%AE%9A%E4%B9%89%EF%BC%9A"><span class="toc-text">我们来看一下官方对 V8 引擎的定义：</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B8%83%E3%80%81V8-%E5%BC%95%E6%93%8E%E7%9A%84%E6%9E%B6%E6%9E%84"><span class="toc-text">七、V8 引擎的架构</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#V8-%E5%BC%95%E6%93%8E%E6%9C%AC%E8%BA%AB%E7%9A%84%E6%BA%90%E7%A0%81%E9%9D%9E%E5%B8%B8%E5%A4%8D%E6%9D%82%EF%BC%8C%E5%A4%A7%E6%A6%82%E6%9C%89%E8%B6%85%E8%BF%87-100w-%E8%A1%8C-C-%E4%BB%A3%E7%A0%81%EF%BC%8C%E9%80%9A%E8%BF%87%E4%BA%86%E8%A7%A3%E5%AE%83%E7%9A%84%E6%9E%B6%E6%9E%84%EF%BC%8C%E6%88%91%E4%BB%AC%E5%8F%AF%E4%BB%A5%E7%9F%A5%E9%81%93%E5%AE%83%E6%98%AF%E5%A6%82%E4%BD%95%E5%AF%B9-JavaScript-%E6%89%A7%E8%A1%8C%E7%9A%84%EF%BC%9A"><span class="toc-text">V8 引擎本身的源码非常复杂，大概有超过 100w 行 C++代码，通过了解它的架构，我们可以知道它是如何对 JavaScript 执行的：</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#Parse-%E6%A8%A1%E5%9D%97%E4%BC%9A%E5%B0%86-JavaScript-%E4%BB%A3%E7%A0%81%E8%BD%AC%E6%8D%A2%E6%88%90-AST%EF%BC%88%E6%8A%BD%E8%B1%A1%E8%AF%AD%E6%B3%95%E6%A0%91%EF%BC%89%EF%BC%8C%E8%BF%99%E6%98%AF%E5%9B%A0%E4%B8%BA%E8%A7%A3%E9%87%8A%E5%99%A8%E5%B9%B6%E4%B8%8D%E7%9B%B4%E6%8E%A5%E8%AE%A4%E8%AF%86-JavaScript-%E4%BB%A3%E7%A0%81%EF%BC%9B"><span class="toc-text">Parse 模块会将 JavaScript 代码转换成 AST（抽象语法树），这是因为解释器并不直接认识 JavaScript 代码；</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Ignition-%E6%98%AF%E4%B8%80%E4%B8%AA%E8%A7%A3%E9%87%8A%E5%99%A8%EF%BC%8C%E4%BC%9A%E5%B0%86-AST-%E8%BD%AC%E6%8D%A2%E6%88%90-ByteCode%EF%BC%88%E5%AD%97%E8%8A%82%E7%A0%81%EF%BC%89"><span class="toc-text">Ignition 是一个解释器，会将 AST 转换成 ByteCode（字节码）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#TurboFan-%E6%98%AF%E4%B8%80%E4%B8%AA%E7%BC%96%E8%AF%91%E5%99%A8%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%B0%86%E5%AD%97%E8%8A%82%E7%A0%81%E7%BC%96%E8%AF%91%E4%B8%BA-CPU-%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E6%89%A7%E8%A1%8C%E7%9A%84%E6%9C%BA%E5%99%A8%E7%A0%81%EF%BC%9B"><span class="toc-text">TurboFan 是一个编译器，可以将字节码编译为 CPU 可以直接执行的机器码；</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%AB%E3%80%81V8-%E5%BC%95%E6%93%8E%E7%9A%84%E5%AE%98%E6%96%B9%E8%A7%A3%E6%9E%90%E5%9B%BE"><span class="toc-text">八、V8 引擎的官方解析图</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B9%9D%E3%80%81V8-%E6%89%A7%E8%A1%8C%E7%9A%84%E7%BB%86%E8%8A%82"><span class="toc-text">九、V8 执行的细节</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%82%A3%E4%B9%88%E6%88%91%E4%BB%AC%E7%9A%84-JavaScript-%E6%BA%90%E7%A0%81%E6%98%AF%E5%A6%82%E4%BD%95%E8%A2%AB%E8%A7%A3%E6%9E%90%EF%BC%88Parse-%E8%BF%87%E7%A8%8B%EF%BC%89%E7%9A%84%E5%91%A2%EF%BC%9F"><span class="toc-text">那么我们的 JavaScript 源码是如何被解析（Parse 过程）的呢？</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/11/09/JavaScript/ES6%E6%96%B0%E7%89%B9%E6%80%A7/index/" title="ES6新特性"><img src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/m9/wallhaven-m9y289.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6新特性"/></a><div class="content"><a class="title" href="/2022/11/09/JavaScript/ES6%E6%96%B0%E7%89%B9%E6%80%A7/index/" title="ES6新特性">ES6新特性</a><time datetime="2022-11-09T12:55:33.000Z" title="发表于 2022-11-09 20:55:33">2022-11-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/10/20/Vue/Vue%20%E5%93%8D%E5%BA%94%E5%BC%8F%E8%A7%A3%E6%9E%90/Vue%E5%93%8D%E5%BA%94%E5%BC%8F%E8%A7%A3%E6%9E%90/" title="Vue 响应式解析"><img src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/z8/wallhaven-z82evv.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue 响应式解析"/></a><div class="content"><a class="title" href="/2022/10/20/Vue/Vue%20%E5%93%8D%E5%BA%94%E5%BC%8F%E8%A7%A3%E6%9E%90/Vue%E5%93%8D%E5%BA%94%E5%BC%8F%E8%A7%A3%E6%9E%90/" title="Vue 响应式解析">Vue 响应式解析</a><time datetime="2022-10-20T12:05:37.000Z" title="发表于 2022-10-20 20:05:37">2022-10-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/08/08/JavaScript/JavaScript%E5%8E%9F%E5%9E%8B%E5%92%8C%E5%8E%9F%E5%9E%8B%E9%93%BE/index/" title="JavaScript原型和原型链"><img src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/z8/wallhaven-z82evv.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JavaScript原型和原型链"/></a><div class="content"><a class="title" href="/2022/08/08/JavaScript/JavaScript%E5%8E%9F%E5%9E%8B%E5%92%8C%E5%8E%9F%E5%9E%8B%E9%93%BE/index/" title="JavaScript原型和原型链">JavaScript原型和原型链</a><time datetime="2022-08-08T09:08:31.000Z" title="发表于 2022-08-08 17:08:31">2022-08-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/08/08/JavaScript/JavaScript%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%A2%9E%E5%BC%BA%E7%9F%A5%E8%AF%86/index/" title="JavaScript对象的增强知识"><img src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/j3/wallhaven-j3qq15.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JavaScript对象的增强知识"/></a><div class="content"><a class="title" href="/2022/08/08/JavaScript/JavaScript%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%A2%9E%E5%BC%BA%E7%9F%A5%E8%AF%86/index/" title="JavaScript对象的增强知识">JavaScript对象的增强知识</a><time datetime="2022-08-08T07:43:36.000Z" title="发表于 2022-08-08 15:43:36">2022-08-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/08/08/JavaScript/JavaScript%E5%87%BD%E6%95%B0%E5%A2%9E%E5%BC%BA%E7%9F%A5%E8%AF%86/index/" title="JavaScript函数增强知识"><img src= "" data-lazy-src="https://dogefs.s3.ladydaily.com/~/source/wallhaven/full/28/wallhaven-2881yx.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JavaScript函数增强知识"/></a><div class="content"><a class="title" href="/2022/08/08/JavaScript/JavaScript%E5%87%BD%E6%95%B0%E5%A2%9E%E5%BC%BA%E7%9F%A5%E8%AF%86/index/" title="JavaScript函数增强知识">JavaScript函数增强知识</a><time datetime="2022-08-08T03:25:40.000Z" title="发表于 2022-08-08 11:25:40">2022-08-08</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://pic1.zhimg.com/v2-4dce785ff4595de55623611ab0055d33_1440w.jpg?source=172ae18b')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Justic</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a><img src= "" data-lazy-src="https://static.dy208.cn/o_1dfilp8ruo521thr1hvf18ji17soa.png">
<a href="http://www.beian.miit.gov.cn/"  style="color:#f72b07" target="_blank">晋ICP备2021014440号-2</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="聊天"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'KgIigedIwh0GobYsWWfPMEdO-gzGzoHsz',
      appKey: 'WpJEQP22asTau19i2tq1yQhU',
      avatar: 'justic',
      serverURLs: '',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !false) {
  if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><div class="aplayer no-destroy" data-id="5076309057" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true" data-lrcType="-1"> </div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = false;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-show-text.min.js" data-mobile="true" data-text="富强,民主,文明,和谐,平等,公正,法治,爱国,敬业,诚信,友善" data-fontsize="15px" data-random="true" async="async"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src= "" data-lazy-src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var qweather_key = 'f854dfdd82d747fca7fd04f092861e87';
  var gaud_map_key = '427416c518f4476a01117be40057a892';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '112.982279,28.19409';
  var clock_default_rectangle_enable = 'false';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.js"></script><!-- hexo injector body_end end --></body></html>